package org.pok.sort;

import java.util.List;

public class Pivot extends Item {

  private Partition left = new Partition();
  private Partition right = new Partition();
  
  public Pivot(Integer value) {
    super(value);
  }

  public Pivot(Item item) {
    super(item.value);
  }

  public void storeIntoSubpartition(Item other) {
    other.storeInto(other.compareTo(this) < 0 ? left : right);
  }

  public List<Item> sortAndJoinSubpartitions() {
    List<Item> sortedList;
    sortedList = left.sort();
    sortedList.add(this);
    sortedList.addAll(right.sort());
    return sortedList;
  }


}
